package com.zgjkhis.modules.system.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zgjkhis.modules.system.domain.InfoSalesDoc;
import com.zgjkhis.modules.system.domain.vo.InfoSaleVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author yzq
 * @Description 供应商
 * @Date 2021/6/23 9:48
 * @Param
 * @return
 **/
@Repository
public interface InfoSalesDocMapper extends BaseMapper<InfoSalesDoc> {

    @Select("<script>select " +
            "doc_id,\n" +
            "doc_name,\n" +
            "\tsum(pay_info_num) pay_info_num,\n" +
            "\tsum(all_info_num) all_info_num,\n" +
            "\tsum(pay_fee) pay_fee,\n" +
            "\tsum(refund_info_num) refund_info_num,\n" +
            "\tsum(refund_fee) refund_fee,\n" +
            "\tsum(xy_info_num) xy_info_num,\n" +
            "\tsum(yp_info_num) yp_info_num,\n" +
            "\tsum(klj_info_num) klj_info_num,\n" +
            "\tsum(xy_pay_info_num) xy_pay_info_num,\n" +
            "\tsum(yp_pay_info_num) yp_pay_info_num,\n" +
            "\tsum(klj_pay_info_num) klj_pay_info_num,\n" +
            "\tsum(xy_pay_info_fee) xy_pay_info_fee,\n" +
            "\tsum(yp_pay_info_fee) yp_pay_info_fee,\n" +
            "\tsum(klj_pay_info_fee) klj_pay_info_fee\n" +
            "from info_sales_doc t \n" +
            "where 1=1 and t.pharmacy_id=#{pharmacyId} \n" +
            " and t.date BETWEEN #{startDate} and #{endDate} GROUP BY\n" +
            "\tdoc_id\n" +
            "</script>")

    List<InfoSaleVo> findAllByDate(@Param("pharmacyId") String pharmacyId,@Param("startDate") String startDate,@Param("endDate") String endDate);


}
